package com.trt.beibei.api.v1;

import com.trt.beibei.manager.rocketmq.ProducerSchedule;
import com.trt.beibei.model.Order;
import com.trt.beibei.repository.OrderRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private OrderRepository orderRepository;

    @Autowired
    private ProducerSchedule producerSchedule;

    @GetMapping("/t")
    @Transactional
    public void getTest() {
        Order order = this.orderRepository.findFirstByOrderNo("B3292062362326").get();
        int res = this.orderRepository.updateStatusByOrderNo("B3292062362326", 2);
        System.out.println(res);
    }

    // 测试mq
    @GetMapping("/push")
    public void pushMessageToMQ() throws Exception {
        producerSchedule.send("TopicTest", "test");
    }


}
